[Security][Workflows] Register workflow steps synchronously using async loaders#265230
Merged
Merged
Conversation
Use the async-loader pattern supported by the workflow extension registry (added in elastic#264788) so that `registerStepDefinition` is called synchronously during `setup()` rather than deferred via `getStartServices().then()`. Each step is now registered with an async loader that checks the feature flag at resolution time and returns `undefined` to skip registration when disabled.
Member
Author
|
/ci |
Member
Author
|
/ci |
semd
reviewed
Apr 23, 2026
| } | ||
| workflowsExtensions.registerStepDefinition(async () => { | ||
| if (!(await isEnabled)) return undefined; | ||
| return renderAlertNarrativeStepDefinition; |
Contributor
There was a problem hiding this comment.
Consider lazy-loading the steps themselves as well. So they do not hit the plugin's main bundle size.
Suggested change
| return renderAlertNarrativeStepDefinition; | |
| return import('./render_alert_narrative_step').then((m) => m.renderAlertNarrativeStepDefinition); |
…duce main bundle size
Member
Author
|
/ci |
smith
pushed a commit
to smith/kibana
that referenced
this pull request
Apr 23, 2026
…nc loaders (elastic#265230) ## Summary Follows up on elastic#264788 (merged by @semd) which added async-loader support to the `ServerStepRegistry` and `PublicStepRegistry`. Previously, `registerStepDefinition` was called inside a deferred `getStartServices().then()` callback — meaning registration happened *after* the `setup()` lifecycle completed. semd flagged this as problematic in review comments on elastic#259159 ([comment 1](elastic#259159 (comment)), [comment 2](elastic#259159 (comment))). This PR applies the fix on the security_solution side: `registerStepDefinition` is now called **synchronously** during `setup()`. Each step is registered with an async loader that checks the feature flag at resolution time and returns `undefined` to skip registration when the flag is disabled. Changes on both server and public sides: - `registerWorkflowSteps` is now a synchronous function accepting `CoreSetup` instead of `CoreStart` - Each step is wrapped in an async loader that defers the feature-flag check to resolution time - `plugin.ts` / `plugin.tsx` call `registerWorkflowSteps` directly in `setup()` (no deferred `.then()`) - New unit tests for both server and public `registerWorkflowSteps` ## Test plan - [ ] `node scripts/jest x-pack/solutions/security/plugins/security_solution/server/workflows/step_types/register_workflow_steps.test.ts` - [ ] `node scripts/jest x-pack/solutions/security/plugins/security_solution/public/workflows/step_types/register_workflow_steps.test.ts` - [ ] Confirm no regression in existing workflow step tests
rbrtj
pushed a commit
to walterra/kibana
that referenced
this pull request
Apr 27, 2026
…nc loaders (elastic#265230) ## Summary Follows up on elastic#264788 (merged by @semd) which added async-loader support to the `ServerStepRegistry` and `PublicStepRegistry`. Previously, `registerStepDefinition` was called inside a deferred `getStartServices().then()` callback — meaning registration happened *after* the `setup()` lifecycle completed. semd flagged this as problematic in review comments on elastic#259159 ([comment 1](elastic#259159 (comment)), [comment 2](elastic#259159 (comment))). This PR applies the fix on the security_solution side: `registerStepDefinition` is now called **synchronously** during `setup()`. Each step is registered with an async loader that checks the feature flag at resolution time and returns `undefined` to skip registration when the flag is disabled. Changes on both server and public sides: - `registerWorkflowSteps` is now a synchronous function accepting `CoreSetup` instead of `CoreStart` - Each step is wrapped in an async loader that defers the feature-flag check to resolution time - `plugin.ts` / `plugin.tsx` call `registerWorkflowSteps` directly in `setup()` (no deferred `.then()`) - New unit tests for both server and public `registerWorkflowSteps` ## Test plan - [ ] `node scripts/jest x-pack/solutions/security/plugins/security_solution/server/workflows/step_types/register_workflow_steps.test.ts` - [ ] `node scripts/jest x-pack/solutions/security/plugins/security_solution/public/workflows/step_types/register_workflow_steps.test.ts` - [ ] Confirm no regression in existing workflow step tests
SoniaSanzV
pushed a commit
to SoniaSanzV/kibana
that referenced
this pull request
Apr 27, 2026
…nc loaders (elastic#265230) ## Summary Follows up on elastic#264788 (merged by @semd) which added async-loader support to the `ServerStepRegistry` and `PublicStepRegistry`. Previously, `registerStepDefinition` was called inside a deferred `getStartServices().then()` callback — meaning registration happened *after* the `setup()` lifecycle completed. semd flagged this as problematic in review comments on elastic#259159 ([comment 1](elastic#259159 (comment)), [comment 2](elastic#259159 (comment))). This PR applies the fix on the security_solution side: `registerStepDefinition` is now called **synchronously** during `setup()`. Each step is registered with an async loader that checks the feature flag at resolution time and returns `undefined` to skip registration when the flag is disabled. Changes on both server and public sides: - `registerWorkflowSteps` is now a synchronous function accepting `CoreSetup` instead of `CoreStart` - Each step is wrapped in an async loader that defers the feature-flag check to resolution time - `plugin.ts` / `plugin.tsx` call `registerWorkflowSteps` directly in `setup()` (no deferred `.then()`) - New unit tests for both server and public `registerWorkflowSteps` ## Test plan - [ ] `node scripts/jest x-pack/solutions/security/plugins/security_solution/server/workflows/step_types/register_workflow_steps.test.ts` - [ ] `node scripts/jest x-pack/solutions/security/plugins/security_solution/public/workflows/step_types/register_workflow_steps.test.ts` - [ ] Confirm no regression in existing workflow step tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follows up on #264788 (merged by @semd) which added async-loader support to the
ServerStepRegistryandPublicStepRegistry.Previously,
registerStepDefinitionwas called inside a deferredgetStartServices().then()callback — meaning registration happened after thesetup()lifecycle completed. semd flagged this as problematic in review comments on #259159 (comment 1, comment 2).This PR applies the fix on the security_solution side:
registerStepDefinitionis now called synchronously duringsetup(). Each step is registered with an async loader that checks the feature flag at resolution time and returnsundefinedto skip registration when the flag is disabled.Changes on both server and public sides:
registerWorkflowStepsis now a synchronous function acceptingCoreSetupinstead ofCoreStartplugin.ts/plugin.tsxcallregisterWorkflowStepsdirectly insetup()(no deferred.then())registerWorkflowStepsTest plan
node scripts/jest x-pack/solutions/security/plugins/security_solution/server/workflows/step_types/register_workflow_steps.test.tsnode scripts/jest x-pack/solutions/security/plugins/security_solution/public/workflows/step_types/register_workflow_steps.test.ts